#include <linux/init.h>
#include <linux/sched.h>
#include <linux/printk.h>
#include <linux/sched/task.h>
#include <linux/delay.h>

static int fair_task0(void *arg)
{
    int cnt = 0;

    printk("T0 start\n");

    preempt_disable();
    printk("T0 preempt_disable\n");
    cnt = 500000000;
    while (cnt--)
    {
    }
    printk("T0 preempt_enable\n");
    preempt_enable();

    while (1)
    {
        if (cnt % 5200000 == 0)
            printk("%s %d\n", current->name, jiffies);
        cnt++;
    }

    return 0;
}

static int fair_task1(void *arg)
{
    int cnt = 0;

    printk("T1 start\n");

    while (1)
    {
        if (cnt % 5200000 == 0)
            printk("%s %d\n", current->name, jiffies);
        cnt++;
    }

    return 0;
}

static int testtask_init(void)
{
    printk("build:%s %s\n", __DATE__, __TIME__);

    kernel_thread(fair_task0, NULL, "fairT0", 0);
    kernel_thread(fair_task1, NULL, "fairT1", 0);

    return 0;
}
late_initcall(testtask_init);
